#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

#define FILENAME "log.txt"
int main()
{
    fprintf(stdout, "hello stdout message\n");
    fprintf(stdout, "hello stdout message\n");
    fprintf(stdout, "hello stdout message\n");
    fprintf(stdout, "hello stdout message\n");
    fprintf(stdout, "hello stdout message\n");

    
    fprintf(stderr, "hello stderr message\n");
    fprintf(stderr, "hello stderr message\n");
    fprintf(stderr, "hello stderr message\n");
    fprintf(stderr, "hello stderr message\n");
    fprintf(stderr, "hello stderr message\n");

    //close(1);

    //int fd = open(FILENAME, O_CREAT|O_WRONLY|O_TRUNC, 0666);
    //if(fd < 0)
    //{
    //    perror("open");
    //    return 1;
    //}
    //// 此处重定向
    //dup2(fd, 1);
    //close(fd);
    //const char* message = "hello Linux\n";
    //int cnt = 5;
    //while(cnt)
    //{
    //    write(1,message, strlen(message) );
    //    cnt--;
    //}
    //

    //close(fd);

    return 0;
}
